import { defineStore } from "pinia";
import { ref } from "vue";

interface RatedItemType {
  _id: string;
  title: string;
  [propname: string]: any;
}

export const useMoviesStore = defineStore("movies", () => {
  const ratedList = ref<RatedItemType[]>([]);

  const getData = () => {
    return new Promise((resolve) => {
      fetch("http://www.pudge.wang:3080/api/rated/list")
        .then((response) => response.json())
        .then((res) => {
          ratedList.value = res.result;
          resolve();
        });
    });
  };

  return { ratedList, getData };
});
